The invention relates to a memory device including a nonvolatile memory wherein data is erased in a unit of a block different from a writing unit of data and also to a controlling method for a nonvolatile memory.
In recent years, a memory device (also referred to as memory card herein) has been spread and used widely as an external storage medium for a host apparatus such as a personal computer, a personal digital assistant, a video camera, a digital camera and a portable telephone set. The memory card is used to store various digital data such as still picture data, moving picture data, audio data and music data.
A host apparatus that utilizes a memory card as an external storage medium sometimes includes an internal storage medium such as a hard disk. Usually, the hard disk is accessed in a logical format from the host apparatus through a file management system such as the MS-DOS (registered trademark). According to the MS-DOS, a cluster is defined as an accessing unit to storage media. In the MS-DOS, an FAT (File Allocation Table) is produced and concatenation relations of data recorded in a recording medium are managed in a unit of a cluster.
Thus, a memory card is known which adopts a popular file management system such as the MS-DOS taking the compatibility with the other recording media into consideration. The memory card adopts a flash memory of the NAND type that is one of nonvolatile memories. The flash memory of the NAND type includes blocks in which data is erased in a batch, and after erasure of data is performed in a unit of a block, new data is written. Such writing of data is performed for each of a plurality of pages provided in the block.
However, in the flash memory of the NAND type, since garbage collection wherein data is erased in a unit of a block is performed, there is a problem that the accessing speed of data is low. Therefore, a memory device wherein blocks of a flash memory are rewritten efficiently to enhance the accessing speed of the flash memory has been proposed and is disclosed in (Japanese Patent Laid-Open No. 2003-308240).
However, according to the flash memory disclosed in (Japanese Patent Laid-Open No. 2003-308240), if the MS-DOS is used as the file management system, there is a tendency that lower logical addresses are used frequently because file allocation information for managing concatenation relations of data is allocated to lower logical addresses. Therefore, lower physical addresses of the flash memory corresponding to the lower logical addresses are used frequently, and there is a problem that the number of times of rewriting of data into part of the physical address region reaches a limit value and rewriting of the flash memory cannot be performed any more although the number of times of rewriting into higher physical addresses is considerably lower than the limit value.